using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SCS.Common.Models;
namespace SCS.DAL.Mapping
{
    public class CommentInClassMap : EntityTypeConfiguration<CommentInClass>
    {
        public CommentInClassMap()
        {
            // Primary Key
            this.HasKey(t => t.commentID);

            // Properties
            this.Property(t => t.comment)
                .IsRequired()
                .HasMaxLength(150);

            // Table & Column Mappings
            this.ToTable("CommentInClass");
            this.Property(t => t.commentID).HasColumnName("commentID");
            this.Property(t => t.learnerID).HasColumnName("learnerID");
            this.Property(t => t.dateOfComment).HasColumnName("dateOfComment");
            this.Property(t => t.isAbsent).HasColumnName("isAbsent");
            this.Property(t => t.incompleteHomework).HasColumnName("incompleteHomework");
            this.Property(t => t.isTalkDuringClass).HasColumnName("isTalkDuringClass");
            this.Property(t => t.comment).HasColumnName("comment");
            this.Property(t => t.isSent).HasColumnName("isSent");
            this.Property(t => t.subjectID).HasColumnName("subjectID");

            // Relationships
            this.HasRequired(t => t.Learner)
                .WithMany(t => t.CommentInClasses)
                .HasForeignKey(d => d.learnerID);
            this.HasRequired(t => t.Subject)
                .WithMany(t => t.CommentInClasses)
                .HasForeignKey(d => d.subjectID);

        }
    }
}
